#include "UdpServer.hpp"
#include "Dictionaries.hpp"
// 接受该服务器上所有ip地址发来的消息
// ./client_udp  localport
int main(int argc,char *argv[])
{
	if (argc != 2)
	{
		std::cerr << "Usage: " << argv[0] << "  localport" << std::endl;
		Die(1);
	}

	uint16_t port = std::stoi(argv[1]);

	ENABLE_CONSOLE_LOG();
	std::shared_ptr<Dictionaries> dic_ptr = std::make_shared<Dictionaries>();
	std::unique_ptr<UdpServer> ser_uptr = std::make_unique<UdpServer>([&dic_ptr](const std::string &work){
		return dic_ptr->translate(work);
	},port);

	ser_uptr->InitServer();
	ser_uptr->Start();
	return 0;
}


// // ./client_udp localip localport
// int main(int argc,char *argv[])
// {
// 	if (argc != 3)
// 	{
// 		std::cerr << "Usage: " << argv[0] << " serverip serverport" << std::endl;
// 		Die(1);
// 	}

// 	std::string ip = argv[1];
// 	uint16_t port = std::stoi(argv[2]);

// 	ENABLE_CONSOLE_LOG();
// 	std::unique_ptr<UdpServer> ser_uptr = std::make_unique<UdpServer>(ip,port);

// 	ser_uptr->InitServer();
// 	ser_uptr->Start();
// 	return 0;
// }